package com.example.iscore;

import java.util.ArrayList;
import java.util.List;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;

public class MemberActivity extends ListActivity {

   private Button btnJoin ;
   private List<String> maListe = new ArrayList<String>();
   private ArrayAdapter<String> adapter ;
 
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_member);
      btnJoin = (Button)findViewById(R.id.button2);
      
	  /* contenu de la liste a remplacer par un select allMembers where idGroup = ?, par la bdd" */
      maListe.add("Duppont Bernard");
      maListe.add("Jean Yves Michel");
      maListe.add("Jean Jacques");
      
      adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, maListe);
      
      OnClickListener listenerJoin = new OnClickListener() {
          @Override
          public void onClick(View v) {
                  EditText edit = (EditText) findViewById(R.id.txtItem);
                  maListe.add(edit.getText().toString());
                  edit.setText("");
                  adapter.notifyDataSetChanged();
          }
      };
      
	    btnJoin.setOnClickListener(listenerJoin);
  
      setListAdapter(adapter);
   }

   
   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
   }

}